{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8ZXV9//HXW3DQECBQMEVFYcQNF9CM4C4RpdafFVwK\nqFVQ67i0EgZry6Sj5Kchcf1N4y4oFesyIBUXqnYUR9BW0BkEBxWqhH0VmAAxlAHm8/vjfO9w5s5N\ncmeSc+89Oe/n43EfuWd/5zuZ87nne849RxGBmZlV10PaHcDMzNrLhcDMrOJcCMzMKs6FwMys4lwI\nzMwqzoXAzKziXAiso0h6jKRJSTs0Me++kkLSjq3Itr1amVPS5yS9r8l5vyRpuKAcIWn/ItZt88+F\noANJulrSS+rGHSfpZ+3K1CxJQ5K+0mB8UzuGiLg2Iroj4oGisnQSScslfb9u3O+nGXfMbOuLiHdE\nxAfnKVvbd+aSFkn6uKTr0weEqyX9SzszLUQuBGbtdQHw3NoRkKS9gYcCz6gbt3+at2qWA0uAg4Fd\ngEOBi9sZaCFyISip+k9r+cN8SYemT1D/KOlWSTdJOlLSyyX9j6Q7JA3mlj1Y0s8lTaR5PyVpUd22\n3pE+lU5I+rQkzSH7QySdJOlKSbdLOkvSHmnaFt0okvaTdIGkuyX9KG27/lP+GyRdK+k2Sf+clnsZ\nMAgcnT5JXprGHydpPK3vKklvmCbjdreJpB0kfSzlGQf+zwzN8UuyHf9BafgFwBrgirpxV0bEjWn9\nT5L0w/TveIWko3K5tujuSX8DN0m6UdLfNviUv7uk/0jtcZGkx6XlakXn0tR+R0vaU9K56fe9Q9JP\nJc20D3l5auvbJH00/bsvSss+LZfxEZKmJO3VYB3PAs6JiBsjc3VEfDm37CMl/bukP6Z/z+Nz074n\n6eO54VWSTp8hb2W5ECxcfw48DHgU8H7gNOBvgD6yHcv7JO2X5n0AWAbsCTwHO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5/5r548D4u27p8ftlNtSwR\nsSndudRsXrhryBa61cC7awOSDmowz4U8+LSoYxpMb+RusnvKz4cfAn9XG9CWD04yK5wLgS10xwNL\n0knY3wLvaDDPCcCJkn4N7A/c2cR6TwV+0Ohk8XYYBnaXdJmkS0m3+jZrFd991CovfR/gnogISccA\nr4uII2ZbzmyhcD+jGfQBn0oPMZkge6SgWWX4iMDMrOJ8jsDMrOJcCMzMKs6FwMys4lwIzMwqzoXA\nzKzi/j+JHU7ybsLJHgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd3b8018e50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "X_train = np.array([\n",
    "    [158, 64],\n",
    "    [170, 86],\n",
    "    [183, 84],\n",
    "    [191, 80],\n",
    "    [155, 49],\n",
    "    [163, 59],\n",
    "    [180, 67],\n",
    "    [158, 54],\n",
    "    [170, 67]\n",
    "])\n",
    "y_train = ['male', 'male', 'male', 'male', 'female', 'female', 'female', 'female', 'female']\n",
    "\n",
    "plt.figure()\n",
    "plt.title('Human Heights and Weights by Sex')\n",
    "plt.xlabel('Height in cm')\n",
    "plt.ylabel('Weight in kg')\n",
    "\n",
    "for i, x in enumerate(X_train):\n",
    "    plt.scatter(x[0], x[1], c='k', marker='x' if y_train[i] == 'male' else 'D')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt4XWWZ9/Hvr8VUQwqFgWZAUKjggcNQTQHPQwSZji8j\nIEhRRgEdO+KMhOI4Ql+UvlooKtqJRwQFcVBbZGRU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2xzhKTrhlh3lqTWIdZ9XdIBI8Vt1iycCKyQIuKHEXHRKA5xFlAxEUTEP0TE70ZxbLO6\nciKwcS19Q/c/JN2aTm9Il2++a5D0srQv+1WS5pfdYbRJukbJuAvfTt+iPRPYE+iR1FPhnDdImpF+\n7pN0Qdrp2U2S2its3ybpivT8t0s6IbPvZ5WM9/BzSYelx14j6e05FJcVlBOBjQcv0paBR1YAn8ys\n6wYWRsShJG/rfr3C/t1Ad0QcTPIWaNarSb79HwBMA94QEV8g6dKgMyI6R4htR+CmSDo9+wXwgQrb\nfJyke4aDI+KvgGWZfZdFxIHAemA+8FaSrlE+WeE4Zttlh0YHYFYDz0bE9NKMpNOAGensUcABmc5b\nd5LUVrb/64Dj0s/fIenGuOSWSPsASpPMPsCvtiG2jUCpnaGX5EJe7ijg5NJMRDyZ2XdJ+nkVsCEi\nnpO0Ko3DrCacCGy8mwC8NiL+N7twG3r13pD5PMC2/595Lrb047Kt+2f3HSzFEhGDaY+lZjXhqiEb\n75YCHy7NSJpeYZub2DJa1MkV1leynqRP+Vr4GfBPpRltPViSWe6cCGy8OxOYkTbC/g74YIVtzgLO\nlnQ7sB/wVBXHvRRYUqmxeDvMB3aRtFrSStLuvc3qxb2PWuGl7wM8GxEh6WTgXRFx7Ej7mY0Xrmc0\ngw7gS+kAJutIhhQ0KwzfEZiZFZzbCMzMCs6JwMys4JwIzMwKzonAzKzgnAjMzAru/wPLG8DYoK03\npQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd3845040d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot for fig2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "X_train = np.array([\n",
    "    [158, 64],\n",
    "    [170, 86],\n",
    "    [183, 84],\n",
    "    [191, 80],\n",
    "    [155, 49],\n",
    "    [163, 59],\n",
    "    [180, 67],\n",
    "    [158, 54],\n",
    "    [170, 67]\n",
    "])\n",
    "y_train = ['male', 'male', 'male', 'male', 'female', 'female', 'female', 'female', 'female']\n",
    "\n",
    "plt.figure()\n",
    "plt.title('Human Heights and Weights by Sex')\n",
    "plt.xlabel('Height in cm')\n",
    "plt.ylabel('Weight in kg')\n",
    "\n",
    "for i, x in enumerate(X_train):\n",
    "    plt.scatter(x[0], x[1], c='k', marker='x' if y_train[i] == 'male' else 'D')\n",
    "plt.scatter(158, 64, s=200, c='k', marker='x')\n",
    "plt.scatter(163, 59, s=200, c='k', marker='D')\n",
    "plt.scatter(158, 54, s=200, c='k', marker='D')\n",
    "plt.scatter(155, 70, s=200, c='k', marker='o')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  6.70820393,  21.9317122 ,  31.30495168,  37.36308338,\n",
       "        21.        ,  13.60147051,  25.17935662,  16.2788206 ,  15.29705854])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.array([[155, 70]])\n",
    "\n",
    "distances = np.sqrt(np.sum((X_train - x)**2, axis=1))\n",
    "distances"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['male', 'female', 'female'], \n",
       "      dtype='|S6')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nearest_neighbor_indices = distances.argsort()[:3]\n",
    "nearest_neighbor_genders = np.take(y_train, nearest_neighbor_indices)\n",
    "nearest_neighbor_genders"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'female'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import Counter\n",
    "b = Counter(np.take(y_train, distances.argsort()[:3]))\n",
    "b.most_common(1)[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0],\n",
       "       [0]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import LabelBinarizer\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "\n",
    "lb = LabelBinarizer()\n",
    "y_train_binarized = lb.fit_transform(y_train)\n",
    "y_train_binarized"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['female'], \n",
       "      dtype='|S6')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "K = 3\n",
    "clf = KNeighborsClassifier(n_neighbors=K)\n",
    "clf.fit(X_train, y_train_binarized.reshape(-1))\n",
    "prediction_binarized = clf.predict(np.array([155, 70]).reshape(1, -1))[0]\n",
    "predicted_label = lb.inverse_transform(prediction_binarized)\n",
    "predicted_label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Binarized labels: [1 1 0 0]\n",
      "Binarized predictions: [0 1 0 0]\n",
      "Predicted labels: ['female' 'male' 'female' 'female']\n"
     ]
    }
   ],
   "source": [
    "X_test = np.array([\n",
    "    [168, 65],\n",
    "    [180, 96],\n",
    "    [160, 52],\n",
    "    [169, 67]\n",
    "])\n",
    "y_test = ['male', 'male', 'female', 'female']\n",
    "y_test_binarized = lb.transform(y_test)\n",
    "print('Binarized labels: %s' % y_test_binarized.T[0])\n",
    "\n",
    "predictions_binarized = clf.predict(X_test)\n",
    "print('Binarized predictions: %s' % predictions_binarized)\n",
    "print('Predicted labels: %s' % lb.inverse_transform(predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 0.75\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import accuracy_score\n",
    "print('Accuracy: %s' % accuracy_score(y_test_binarized, predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Precision: 1.0\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import precision_score\n",
    "print('Precision: %s' % precision_score(y_test_binarized, predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Recall: 0.5\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import recall_score\n",
    "print('Recall: %s' % recall_score(y_test_binarized, predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F1 score: 0.666666666667\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import f1_score\n",
    "print('F1 score: %s' % f1_score(y_test_binarized, predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Matthews correlation coefficient: 0.57735026919\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import matthews_corrcoef\n",
    "print('Matthews correlation coefficient: %s' % matthews_corrcoef(y_test_binarized, predictions_binarized))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             precision    recall  f1-score   support\n",
      "\n",
      "       male       1.00      0.50      0.67         2\n",
      "\n",
      "avg / total       1.00      0.50      0.67         2\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import classification_report\n",
    "print(classification_report(y_test_binarized, predictions_binarized, target_names=['male'], labels=[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
